#include<iostream>
#include<vector>
#include<string>
#include<string.h>
using namespace std;
const int maxn = 5001;
int a[maxn][maxn];


int main()
{
    string s1, s2;
    memset(a, 0, sizeof(a));
    int c0, c1, c2;
    cin >> s1 >> s2;
    cin >> c0 >> c1 >> c2;
    if(c2 > c0 + c1) c2 = c0 + c1;
    if(s1[0] == s2[0]) a[0][0] = 0;
    for(int i = 0; i <= s1.size(); i++)
    {
        a[i][0] = c1*i;
        
    }
    for(int i = 0; i <= s2.size(); i++)
    {
        a[0][i] = c0*i;
        
    }
    for(int i = 1; i <= s1.size(); i++)
    {
        for(int j = 1; j <= s2.size(); j++)
        {
            int value = min(a[i-1][j]+c1, a[i][j-1]+c0);  // 插入一个字符，即插入s2的最后一个字符
            int value1 = 0;
            if(s1[i-1] != s2[j-1])  // attention here!  one first is 1, other is 0
            {
                value1 += c2;
            }
            value1 += a[i-1][j-1];
            a[i][j] = min(value, value1);
        }
    }
    // for(int i = 0; i < s1.size(); i++)
    // {
    //     for(int j = 0; j < s2.size(); j++)
    //     {
    //         cout << a[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    if(!s1.size()) cout << c0*s2.size() << endl;
    else if(!s2.size()) cout << c1*s1.size() << endl;
    else cout << a[s1.size()][s2.size()] << endl;
    
    return 0;
}